let persons : {
    name:string,
    age?:number
}

persons={name:'chen'}


let count : (a:number,b:number) => number
count = function(a,b){
    return a+b;
}   

//数组方式1：
let arr1:string[]
arr1 = ['a','b']

//数组方式2：
let arr2:Array<number>  //泛型
arr2 = [100,200]


class Cat {
    name:string;
    age:number;
    constructor(name:string,age:number){
        this.name=name;
        this.age=age;
    }
    speak(){
        console.log(`我叫${this.name},今年${this.age}`);
    }
}

const p1 = new Cat('xiaohong',23)
console.log(p1)
p1.speak()

class RedCat extends Cat{
    grade:string;
     
    constructor(name:string,age:number,grade:string){
        super(name,age);
        this.grade=grade;

    } 
    override speak (){
        console.log(`${this.name}正在学习中`);
    }
}
const redSmallCat = new RedCat('hongxiaomi',12)

